package com.ssm.service.imp;

import com.github.pagehelper.PageHelper;
import com.ssm.mapper.ProductTypeMapper;
import com.ssm.pojo.ProductType;
import com.ssm.service.ProductTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductTypeServiceImp implements ProductTypeService{

    @Autowired
    private ProductTypeMapper typeMapper;

    public void insert(ProductType productType) {
        typeMapper.insert(productType);
    }

    public void update(ProductType productType) {
        typeMapper.update(productType);
    }

    public void delete(String NO) {
        typeMapper.delete(NO);
    }

    public List<ProductType> selectProductTypesPage(Integer pageNum, Integer pageSize, String NO) {
        if(pageNum!=null && pageSize!=null){
            PageHelper.startPage(pageNum,pageSize);
        }
        List<ProductType> productTypes = typeMapper.selectProductTypesPage(NO);
        return productTypes;
    }

    public Integer countSize(String NO) {
        Integer size = typeMapper.countSize(NO);
        return size;
    }

    public ProductType selectProductTypeByNO(String NO) {
        ProductType type = typeMapper.selectByNO(NO);
        return type;
    }
}
